package com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeHistoricalRecord;

import android.view.View;
import android.widget.TextView;

import com.example.anew.journey.mynewjourney.R;
import com.example.anew.journey.mynewjourney.base.FirstChangeAllBaseActivity;
import com.example.anew.journey.mynewjourney.customview.MyHistoricalDataCustomView;
import com.example.anew.journey.mynewjourney.customview.MyHorizontalScrollView;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeCardiacDetection.bean.HistoricalDataViewBean;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeHistoricalRecord.persenter.FirstChangeHistoricalRecordPersenter;
import com.example.anew.journey.mynewjourney.firstchangelogic.firstChangeHistoricalRecord.view.ISFirstChangeHistoricalRecordView;

/**
 * 杭州惟君医疗科技有限公司14
 * Created by 20433 on 2018/3/20
 */

public class FirstChangeHistoricalRecordActivity extends FirstChangeAllBaseActivity implements ISFirstChangeHistoricalRecordView {

    private MyHorizontalScrollView my_horizontalScrollview;
    private int p ;
    private FirstChangeHistoricalRecordPersenter mFirstChangeHistoricalRecordPersenter = new FirstChangeHistoricalRecordPersenter(this);
    private MyHistoricalDataCustomView myhistorcaldatecustomview;
    private TextView tv_date;
    private TextView tv_heart_rate;
    private TextView tv_state;

    /**
     * @desc 主要内容的布局资源填充进来
     */
    @Override
    protected View setMainContentView() {
        View view = View.inflate(this, R.layout.activity_first_change_historical_record, null);
        return view;
    }
    /**
     * @desc 初始化数据 onCreate()
     */
    @Override
    protected void initView(View view) {
        displayToolbar();
        displayReturn();
        displayTvName();

        setToolbarBg(0xff2196F3);
        setReturnrePictuResources(R.mipmap.return_02);
        setTvNameEachAttribute(20, 0xffffffff, "历史记录");
        my_horizontalScrollview = (MyHorizontalScrollView)findViewById(R.id.activity_first_change_historical_record_my_horizontalScrollview);
        myhistorcaldatecustomview = (MyHistoricalDataCustomView)findViewById(R.id.activity_first_change_historical_record_myhistorcaldatecustomview);
        tv_date = (TextView)findViewById(R.id.activity_first_change_historical_record_date_list_tv_date);
        tv_heart_rate = (TextView)findViewById(R.id.activity_first_change_historical_record_tv_heart_rate);
        tv_state = (TextView)findViewById(R.id.activity_first_change_historical_record_tv_state);
        mFirstChangeHistoricalRecordPersenter.initDate(my_horizontalScrollview, myhistorcaldatecustomview,this);
    }


    /**
     * @desc Activity 销毁 释放资源
     */

    @Override
    protected void releaseResources() {

    }
    /**
     * @desc 网络监听 用于提示用户有网络了
     */
    @Override
    protected void promptHaveInternet() {

    }
    /**
     * @desc 网络监听 用于提示用户没有网络了
     */
    @Override
    protected void promptNoInternet() {

    }

    /**
     * @desc 点击分享按钮
     */
    @Override
    protected void onClickShared() {

    }
    /**
     * @desc 点击发布按钮
     */
    @Override
    protected void onClickRelease() {

    }
    /**
     * @desc 点击返回按钮
     */
    @Override
    protected void onClickReturn() {
        finish();
    }

    //设置中心数据
    @Override
    public void setMiddleDate(HistoricalDataViewBean bean) {
       int yvule =  bean.getYvalue();
        tv_heart_rate.setText(yvule+" bpm");
        tv_date.setText(bean.getDate());
        if(yvule < 120){
            tv_state.setText("过慢");
            tv_state.setTextColor(0xffFF9800);
        }else if(yvule > 160){
            tv_state.setText("过快");
            tv_state.setTextColor(0xffFF4800);
        }else{
            tv_state.setText("正常");
            tv_state.setTextColor(0xff323232);
        }
    }
}
